package com.wangzhenyu.learn.test.android_.intent_

import android.content.Intent
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import androidx.fragment.app.FragmentActivity
import com.wangzhenyu.common.util.log.LogUtil

//contract契约
@Suppress("UNUSED")
object InstanceOfIntent {

    //检查可响应任务的Activity
    fun test01(activity: FragmentActivity) {

        val intent = Intent(Intent.CATEGORY_HOME)

        val resolvedActivity: ResolveInfo? = activity.packageManager.resolveActivity(
            intent,
            PackageManager.MATCH_DEFAULT_ONLY
        )
        if (resolvedActivity != null) {
            LogUtil.default01("不是空的")
        } else {
            LogUtil.default01("没有这个应用")
        }

    }
}